package com.el.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.el.bojo.User;

public class UserServlet extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=utf-8");
	String userName=request.getParameter("userName");
	String password =request.getParameter("password");
	String[] habits=request.getParameterValues("habit");
	User user =new User();
	user.setName(userName);
	user.setPassword(password);
	user.setHabits(java.util.Arrays.asList(habits));
	request.setAttribute("userObj", user);
	request.getRequestDispatcher("regSuccess.jsp").forward(request, response);
	
	}

}
